package com.dtyunxi.generate;

import com.dtyunxi.generate.base.CodeGenerateBase;
import com.dtyunxi.utils.ResourceUtil;
import com.dtyunxi.utils.StringUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <p/>
 * <br>==========================
 * <br> 公司：云徙科技
 * <br> 开发：wu.yingnan@dtyunxi.com
 * <br> 版本：1.0
 * <br> 创建时间：2017/4/14
 * <br>==========================
 */
public class ServiceImplGenerateService extends CodeGenerateBase {

    public ServiceImplGenerateService(){
        setTemplateFile("serviceImpl.ftl");
        setSourcePackage(ResourceUtil.get("serviceImpl.package"));
    }

    public void init(String table, String tableComment) {
        String className = StringUtil.getCamelString(table);
        setSourceFile(new StringBuilder("").append(className).append("ServiceImpl.java").toString());
        Map<String, Object> root = new HashMap<String, Object>();
        root.put("className", className);
        root.put("packageName", getSourcePackage());
        root.put("author", ResourceUtil.get("author"));
        root.put("tableComment", tableComment);
        root.put("date", new SimpleDateFormat("yyyy/MM/dd").format(new Date()));
        setAttr(root);
    }


}
